{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 4,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.5 64-bit ('base': conda)"
  },
  "interpreter": {
   "hash": "bf8603ba8d0f844d3c4d591ed2b6601c5fc0e9006cfdb0e24f6f88db420a2876"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#开始批量处理xml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "from os import getcwd\n",
    "from xml.etree import ElementTree as ET\n",
    "import numpy as np\n",
    "# 定义一个创建一级分支object的函数\n",
    "def create_object(root, xi, yi, xa, ya, obj_name):  # 参数依次，树根，xmin，ymin，xmax，ymax\n",
    "    # 创建一级分支object\n",
    "    _object = ET.SubElement(root, 'object')\n",
    "    # 创建二级分支\n",
    "    name = ET.SubElement(_object, 'name')\n",
    "    # print(obj_name)\n",
    "    name.text = str(obj_name)\n",
    "    pose = ET.SubElement(_object, 'pose')\n",
    "    pose.text = 'Unspecified'\n",
    "    truncated = ET.SubElement(_object, 'truncated')\n",
    "    truncated.text = '0'\n",
    "    difficult = ET.SubElement(_object, 'difficult')\n",
    "    difficult.text = '0'\n",
    "    # 创建bndbox\n",
    "    bndbox = ET.SubElement(_object, 'bndbox')\n",
    "    xmin = ET.SubElement(bndbox, 'xmin')\n",
    "    xmin.text = '%s' % xi\n",
    "    ymin = ET.SubElement(bndbox, 'ymin')\n",
    "    ymin.text = '%s' % yi\n",
    "    xmax = ET.SubElement(bndbox, 'xmax')\n",
    "    xmax.text = '%s' % xa\n",
    "    ymax = ET.SubElement(bndbox, 'ymax')\n",
    "    ymax.text = '%s' % ya\n",
    "\n",
    "\n",
    "# 创建xml文件的函数\n",
    "def create_tree(image_name, h, w, imgdir):\n",
    "    global annotation\n",
    "    # 创建树根annotation\n",
    "    annotation = ET.Element('annotation')\n",
    "    # 创建一级分支folder\n",
    "    folder = ET.SubElement(annotation, 'folder')\n",
    "    # 添加folder标签内容\n",
    "    folder.text = (imgdir)\n",
    "\n",
    "    # 创建一级分支filename\n",
    "    filename = ET.SubElement(annotation, 'filename')\n",
    "    filename.text = image_name\n",
    "\n",
    "    # 创建一级分支path\n",
    "    path = ET.SubElement(annotation, 'path')\n",
    "\n",
    "    path.text = getcwd() + '\\{}\\{}'.format(imgdir, image_name)  # 用于返回当前工作目录\n",
    "\n",
    "    # 创建一级分支source\n",
    "    source = ET.SubElement(annotation, 'source')\n",
    "    # 创建source下的二级分支database\n",
    "    database = ET.SubElement(source, 'database')\n",
    "    database.text = 'Unknown'\n",
    "\n",
    "    # 创建一级分支size\n",
    "    size = ET.SubElement(annotation, 'size')\n",
    "    # 创建size下的二级分支图像的宽、高及depth\n",
    "    width = ET.SubElement(size, 'width')\n",
    "    width.text = str(w)\n",
    "    height = ET.SubElement(size, 'height')\n",
    "    height.text = str(h)\n",
    "    depth = ET.SubElement(size, 'depth')\n",
    "    depth.text = '3'\n",
    "\n",
    "    # 创建一级分支segmented\n",
    "    segmented = ET.SubElement(annotation, 'segmented')\n",
    "    segmented.text = '0'\n",
    "\n",
    "\n",
    "def pretty_xml(element, indent, newline, level=0):  # elemnt为传进来的Elment类，参数indent用于缩进，newline用于换行\n",
    "    if element:  # 判断element是否有子元素\n",
    "        if (element.text is None) or element.text.isspace():  # 如果element的text没有内容\n",
    "            element.text = newline + indent * (level + 1)\n",
    "        else:\n",
    "            element.text = newline + indent * (level + 1) + element.text.strip() + newline + indent * (level + 1)\n",
    "            # else:  # 此处两行如果把注释去掉，Element的text也会另起一行\n",
    "            # element.text = newline + indent * (level + 1) + element.text.strip() + newline + indent * level\n",
    "    temp = list(element)  # 将element转成list\n",
    "    for subelement in temp:\n",
    "        if temp.index(subelement) < (len(temp) - 1):  # 如果不是list的最后一个元素，说明下一个行是同级别元素的起始，缩进应一致\n",
    "            subelement.tail = newline + indent * (level + 1)\n",
    "        else:  # 如果是list的最后一个元素， 说明下一行是母元素的结束，缩进应该少一个\n",
    "            subelement.tail = newline + indent * level\n",
    "        pretty_xml(subelement, indent, newline, level=level + 1)  # 对子元素进行递归操作\n",
    "#对68个人脸关键点进行处理，返回人脸框（最上端从眉毛开始，最下端为下巴）\n",
    "def darw_face_rect(face_landmarks):\n",
    "    x_stance_list = []\n",
    "    y_stance_list = []\n",
    "    for point in face_landmarks:\n",
    "        x_stance_list.append(point[0])\n",
    "        y_stance_list.append(point[1])\n",
    "    x_min = min(x_stance_list)\n",
    "    x_max = max(x_stance_list)\n",
    "    y_min = min(y_stance_list)\n",
    "    y_max = max(y_stance_list)\n",
    "    print([x_min,y_min,x_max,y_max])\n",
    "    return [x_min,y_min,x_max,y_max]\n",
    "    \n",
    "    # 读取数据\n",
    "with open('ffhq-dataset-v2.json', 'r') as f:\n",
    "    data = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "tags": [
     "outputPrepend"
    ]
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      " 473.22], [405.53, 475.73], [441.3, 495.12], [403.18, 498.98], [363.0, 498.58], [583.02, 496.51], [619.23, 471.49], [659.44, 469.77], [693.15, 482.79], [663.4, 497.3], [623.19, 499.02], [373.34, 737.73], [439.2, 708.76], [498.53, 698.76], [536.56, 703.37], [572.56, 699.49], [612.69, 706.23], [646.3, 729.83], [611.94, 782.38], [573.7, 798.93], [533.45, 804.88], [493.28, 802.37], [434.22, 784.86], [392.4, 735.8], [498.34, 717.8], [536.38, 722.41], [572.38, 718.53], [625.13, 731.74], [569.82, 762.93], [533.8, 768.92], [495.73, 768.55]]\n",
      "[155.56, 387.44, 774.88, 950.87]\n",
      "34985_face.jpg D:/Notebook/CMFD/34000/34985_face.jpg [[123.03, 511.14], [133.45, 592.37], [146.33, 674.67], [171.01, 752.72], [216.7, 818.81], [282.87, 863.34], [361.45, 892.76], [441.9, 912.45], [516.46, 912.02], [575.45, 890.78], [618.88, 848.72], [658.32, 799.67], [687.65, 741.55], [707.18, 680.34], [720.72, 619.47], [727.26, 562.58], [732.47, 503.35], [247.24, 450.27], [295.46, 407.96], [355.33, 380.66], [423.69, 376.95], [483.57, 394.16], [579.71, 392.55], [627.1, 379.16], [675.27, 380.15], [717.41, 403.13], [733.01, 446.79], [538.56, 476.58], [542.84, 511.23], [549.4, 543.35], [557.34, 579.01], [480.85, 632.47], [512.56, 640.38], [543.06, 648.35], [567.86, 639.78], [590.12, 628.95], [322.93, 493.08], [364.74, 465.55], [409.06, 461.95], [438.59, 496.43], [406.66, 506.59], [362.16, 506.59], [588.9, 495.5], [623.26, 463.57], [660.5, 462.75], [681.38, 492.89], [661.71, 507.19], [624.4, 506.81], [409.1, 728.99], [465.76, 709.07], [518.08, 697.82], [541.19, 702.58], [566.12, 696.41], [593.02, 704.58], [614.45, 722.66], [589.89, 757.68], [563.08, 773.56], [536.89, 778.59], [511.64, 778.76], [463.01, 769.37], [427.16, 729.21], [515.26, 712.4], [539.31, 712.3], [564.43, 709.74], [596.4, 722.44], [564.05, 747.05], [537.92, 753.28], [513.87, 753.38]]\n",
      "[123.03, 376.95, 733.01, 912.45]\n",
      "34986_face.jpg D:/Notebook/CMFD/34000/34986_face.jpg [[190.36, 482.03], [196.99, 567.45], [210.52, 650.13], [232.33, 730.09], [270.68, 803.2], [325.59, 866.73], [388.8, 919.25], [454.81, 956.64], [523.65, 965.1], [585.7, 941.87], [632.68, 892.42], [676.93, 836.08], [714.3, 772.82], [742.04, 706.79], [757.41, 635.21], [763.13, 562.22], [761.97, 487.84], [260.72, 443.67], [303.52, 407.98], [360.04, 394.37], [417.87, 401.43], [470.14, 423.62], [583.11, 418.44], [623.11, 397.9], [668.6, 388.39], [714.02, 398.16], [738.71, 434.05], [530.57, 485.78], [533.14, 549.15], [535.71, 609.76], [538.29, 670.38], [463.87, 685.31], [496.88, 699.18], [532.66, 713.06], [564.37, 702.13], [591.97, 685.69], [328.08, 489.32], [362.59, 464.63], [405.28, 467.51], [441.0, 499.29], [406.55, 504.7], [362.47, 504.57], [584.25, 498.33], [618.79, 464.0], [660.12, 459.99], [691.73, 483.5], [664.13, 501.32], [622.8, 503.96], [386.58, 736.05], [443.05, 737.59], [492.63, 740.49], [522.91, 747.47], [553.23, 743.42], [589.04, 743.53], [631.75, 742.28], [590.23, 806.9], [552.97, 830.2], [519.9, 834.24], [486.86, 828.63], [437.36, 799.56], [404.47, 742.99], [492.6, 751.51], [524.26, 757.11], [553.2, 754.44], [613.81, 751.87], [551.68, 801.27], [521.37, 805.32], [488.32, 799.71]]\n",
      "[190.36, 388.39, 763.13, 965.1]\n",
      "34987_face.jpg D:/Notebook/CMFD/34000/34987_face.jpg [[196.45, 466.01], [198.61, 553.87], [202.04, 638.91], [211.6, 721.6], [239.4, 799.2], [288.05, 865.06], [358.82, 916.37], [440.3, 949.03], [522.52, 954.19], [598.48, 942.98], [657.14, 907.4], [708.57, 855.36], [744.57, 789.97], [765.54, 717.19], [775.98, 641.4], [779.88, 562.0], [780.85, 482.33], [263.81, 442.12], [299.84, 396.44], [359.89, 376.76], [419.88, 387.6], [475.5, 412.79], [564.94, 414.72], [615.52, 391.16], [670.32, 384.75], [721.55, 404.58], [746.58, 450.38], [522.19, 468.61], [524.01, 520.01], [525.74, 572.38], [529.32, 625.91], [458.45, 655.36], [489.97, 665.36], [524.41, 675.66], [554.82, 666.84], [582.51, 655.78], [329.69, 483.1], [363.22, 462.77], [403.59, 462.82], [441.37, 489.2], [402.96, 499.19], [360.63, 498.95], [585.03, 490.57], [621.76, 467.61], [660.09, 468.44], [688.5, 489.95], [660.53, 503.93], [621.32, 502.03], [407.78, 759.68], [453.98, 740.6], [495.22, 731.87], [524.98, 739.73], [555.3, 731.89], [589.44, 735.26], [624.18, 752.48], [593.4, 784.89], [561.82, 795.57], [529.93, 799.31], [497.45, 799.06], [455.9, 791.02], [427.57, 758.68], [494.27, 751.47], [526.46, 754.65], [556.39, 750.71], [608.47, 751.91], [559.14, 762.8], [528.13, 767.62], [496.92, 764.54]]\n",
      "[196.45, 376.76, 780.85, 954.19]\n",
      "34988_face.jpg D:/Notebook/CMFD/34000/34988_face.jpg [[217.95, 438.91], [219.92, 517.94], [225.65, 596.88], [242.62, 673.66], [276.39, 744.37], [321.26, 807.28], [373.61, 868.11], [436.88, 913.61], [506.92, 928.82], [576.13, 910.15], [633.25, 859.78], [678.75, 796.51], [720.34, 727.69], [752.48, 657.22], [769.43, 581.48], [775.09, 506.02], [777.02, 432.54], [281.28, 410.97], [324.04, 389.2], [371.18, 391.79], [416.72, 405.72], [458.72, 429.16], [579.25, 429.93], [616.33, 406.41], [657.35, 390.33], [698.61, 383.65], [732.9, 399.75], [518.37, 480.4], [521.51, 531.16], [522.73, 580.08], [523.99, 630.89], [446.98, 638.45], [483.16, 654.5], [521.17, 668.62], [556.59, 654.56], [588.21, 638.71], [332.17, 488.79], [370.04, 497.27], [400.15, 496.52], [435.81, 491.86], [400.24, 500.28], [370.08, 499.15], [590.11, 488.03], [625.96, 490.9], [656.07, 490.15], [687.82, 479.95], [656.07, 490.15], [627.89, 492.74], [359.85, 693.34], [418.14, 690.01], [474.73, 694.25], [514.43, 700.8], [553.81, 694.17], [604.53, 689.14], [651.57, 687.97], [604.56, 766.34], [552.71, 801.52], [511.46, 808.2], [468.03, 803.63], [410.69, 769.28], [378.9, 702.28], [475.1, 709.31], [512.93, 715.9], [552.3, 709.27], [633.03, 699.73], [551.83, 765.77], [510.57, 772.44], [470.91, 767.78]]\n",
      "[217.95, 383.65, 777.02, 928.82]\n",
      "34989_face.jpg D:/Notebook/CMFD/34000/34989_face.jpg [[297.95, 513.79], [289.22, 580.51], [292.27, 648.77], [307.35, 716.61], [328.57, 783.26], [360.37, 845.3], [392.69, 903.42], [429.96, 954.2], [487.29, 973.67], [553.84, 968.4], [623.74, 937.63], [691.24, 894.56], [746.04, 841.85], [783.01, 772.84], [801.38, 693.41], [816.09, 611.5], [823.2, 526.61], [296.19, 435.72], [316.76, 400.49], [361.22, 396.32], [401.66, 407.6], [441.07, 426.73], [539.54, 421.64], [592.19, 400.59], [649.19, 392.08], [709.51, 403.96], [752.5, 441.52], [482.01, 479.98], [473.11, 532.71], [460.3, 584.92], [449.7, 635.43], [406.34, 661.7], [434.5, 675.36], [466.83, 687.57], [508.13, 677.01], [547.47, 666.18], [339.86, 483.35], [365.97, 466.8], [399.59, 469.2], [434.05, 495.67], [397.96, 496.93], [364.34, 494.53], [583.54, 497.26], [618.78, 471.93], [656.84, 470.92], [696.25, 490.04], [661.1, 499.42], [621.08, 500.17], [380.64, 736.18], [406.49, 721.59], [445.06, 716.66], [477.65, 726.91], [514.51, 719.76], [582.94, 730.7], [650.34, 749.5], [589.31, 819.36], [523.6, 848.68], [481.36, 851.14], [442.63, 842.09], [405.78, 803.33], [398.04, 740.45], [443.69, 742.43], [478.5, 750.97], [516.81, 748.0], [631.91, 753.08], [518.92, 808.15], [480.86, 809.16], [444.35, 798.4]]\n",
      "[289.22, 392.08, 823.2, 973.67]\n",
      "34990_face.jpg D:/Notebook/CMFD/34000/34990_face.jpg [[203.38, 466.89], [206.1, 548.74], [214.76, 627.9], [232.28, 704.47], [267.52, 775.88], [317.66, 839.1], [382.93, 888.3], [451.34, 931.77], [520.87, 946.1], [588.58, 931.16], [645.75, 886.63], [694.61, 830.1], [732.26, 761.47], [758.36, 689.47], [775.82, 614.23], [787.46, 538.77], [790.45, 460.06], [270.07, 402.28], [303.58, 365.61], [353.69, 352.92], [405.83, 363.66], [451.48, 391.67], [574.14, 390.51], [621.78, 366.05], [668.98, 353.25], [718.21, 363.88], [748.83, 403.0], [513.06, 461.17], [513.87, 516.67], [514.67, 572.17], [515.48, 627.67], [458.76, 660.54], [487.57, 670.4], [516.5, 677.34], [545.99, 669.71], [569.87, 656.02], [334.01, 486.46], [366.74, 470.19], [404.75, 468.72], [436.04, 490.35], [400.62, 500.68], [362.72, 499.23], [584.94, 490.18], [623.62, 471.22], [658.82, 466.72], [690.34, 482.52], [660.52, 498.9], [622.62, 497.46], [393.76, 757.33], [441.07, 741.62], [485.35, 728.71], [517.2, 735.76], [543.77, 728.01], [584.36, 735.4], [627.65, 748.72], [590.66, 799.86], [548.74, 827.46], [519.25, 835.1], [484.27, 833.77], [438.41, 811.58], [411.14, 760.91], [484.24, 757.86], [516.31, 759.08], [545.69, 754.36], [610.04, 750.97], [547.27, 789.45], [517.89, 794.17], [485.94, 790.04]]\n",
      "[203.38, 352.92, 790.45, 946.1]\n",
      "34991_face.jpg D:/Notebook/CMFD/34000/34991_face.jpg [[236.53, 480.38], [229.13, 558.05], [229.83, 640.92], [244.79, 717.49], [282.89, 786.2], [334.91, 841.91], [391.19, 892.92], [449.37, 937.12], [515.13, 952.95], [585.26, 943.91], [643.59, 899.6], [700.52, 849.75], [753.67, 791.13], [790.62, 722.1], [808.02, 642.83], [808.38, 558.78], [798.9, 479.7], [265.83, 461.02], [306.6, 424.29], [365.67, 418.03], [423.33, 428.65], [479.3, 450.56], [543.85, 441.79], [595.17, 414.63], [651.68, 401.78], [710.18, 406.75], [753.45, 443.84], [513.06, 499.32], [515.69, 552.96], [517.04, 603.31], [516.26, 656.01], [442.09, 674.21], [477.45, 687.04], [513.92, 699.81], [552.55, 687.84], [587.87, 677.14], [336.6, 487.8], [365.0, 472.96], [402.05, 474.51], [437.85, 496.28], [401.13, 501.44], [364.19, 502.13], [587.94, 495.65], [620.21, 468.3], [658.16, 465.32], [690.33, 481.67], [661.98, 497.62], [623.98, 499.48], [385.65, 734.11], [432.7, 734.04], [473.04, 734.31], [505.89, 741.66], [540.32, 735.49], [581.95, 739.05], [630.22, 741.17], [582.64, 775.99], [540.99, 794.83], [505.28, 797.7], [468.07, 792.81], [431.04, 768.85], [403.8, 738.82], [472.64, 748.89], [505.43, 755.12], [539.97, 751.19], [612.51, 745.4], [538.96, 753.48], [504.48, 758.53], [471.68, 752.3]]\n",
      "[229.13, 401.78, 808.38, 952.95]\n",
      "34992_face.jpg D:/Notebook/CMFD/34000/34992_face.jpg [[203.75, 519.13], [209.68, 590.99], [217.6, 658.17], [226.04, 726.81], [247.48, 792.84], [288.51, 854.24], [355.09, 902.58], [433.95, 936.95], [516.94, 949.3], [596.33, 939.36], [662.77, 903.18], [717.39, 854.28], [753.95, 791.88], [769.61, 721.98], [777.3, 653.91], [787.5, 588.27], [795.27, 519.5], [273.35, 457.28], [311.95, 418.38], [366.63, 403.29], [426.45, 403.62], [486.12, 416.61], [554.6, 415.19], [607.03, 401.23], [662.52, 402.43], [711.53, 421.85], [740.38, 462.03], [519.94, 473.59], [522.37, 528.12], [525.67, 581.35], [528.02, 636.57], [456.8, 660.18], [489.07, 672.61], [523.59, 683.91], [555.22, 673.02], [582.85, 660.23], [332.53, 491.34], [366.22, 469.44], [402.03, 470.33], [436.75, 497.14], [401.21, 499.81], [364.71, 498.83], [588.21, 496.8], [622.32, 471.42], [658.3, 470.93], [687.21, 493.51], [659.65, 499.97], [623.76, 499.77], [374.03, 726.04], [430.37, 720.31], [483.43, 718.4], [521.41, 724.49], [557.98, 719.14], [605.06, 720.01], [651.63, 725.04], [608.09, 764.04], [562.08, 783.02], [523.6, 786.73], [485.27, 783.42], [429.5, 767.39], [389.9, 728.7], [483.98, 736.78], [521.44, 741.39], [558.71, 736.13], [636.37, 728.8], [560.3, 757.45], [521.73, 761.85], [484.1, 758.62]]\n",
      "[203.75, 401.23, 795.27, 949.3]\n",
      "34993_face.jpg D:/Notebook/CMFD/34000/34993_face.jpg [[244.43, 508.23], [243.03, 582.95], [250.35, 660.24], [272.79, 736.1], [306.2, 802.44], [345.69, 861.42], [391.26, 913.05], [446.69, 943.4], [504.93, 949.75], [557.27, 929.54], [594.82, 878.51], [630.05, 820.93], [658.08, 758.94], [679.08, 694.23], [700.23, 631.19], [712.83, 567.28], [711.98, 504.63], [301.52, 412.97], [341.77, 390.51], [390.34, 384.21], [440.02, 389.68], [486.25, 412.43], [583.46, 418.48], [617.31, 400.01], [655.32, 389.63], [689.72, 394.85], [712.58, 421.51], [534.78, 477.34], [539.56, 527.74], [547.69, 577.83], [554.14, 628.08], [485.24, 670.2], [512.76, 674.38], [540.44, 680.23], [563.48, 672.96], [586.21, 662.33], [345.65, 485.08], [377.98, 468.45], [411.9, 468.63], [444.53, 490.97], [409.72, 499.35], [375.8, 499.17], [583.42, 489.68], [615.11, 466.34], [647.2, 464.99], [670.63, 479.73], [650.06, 495.24], [616.14, 495.06], [411.82, 772.09], [465.67, 750.04], [511.76, 735.5], [537.6, 739.83], [560.65, 732.57], [585.45, 743.78], [606.0, 763.87], [579.66, 790.1], [554.05, 806.09], [529.01, 810.15], [501.81, 809.34], [460.21, 799.72], [428.78, 772.18], [509.11, 761.18], [534.63, 762.15], [558.0, 758.25], [592.55, 765.15], [554.79, 760.24], [531.59, 765.83], [504.39, 765.02]]\n",
      "[243.03, 384.21, 712.83, 949.75]\n",
      "34994_face.jpg D:/Notebook/CMFD/34000/34994_face.jpg [[75.57, 478.37], [78.23, 577.06], [79.11, 668.26], [98.37, 762.2], [157.21, 833.11], [250.52, 886.03], [348.97, 923.82], [439.78, 954.68], [518.83, 957.77], [570.76, 929.36], [598.83, 867.05], [631.77, 801.12], [661.82, 744.88], [684.23, 681.72], [702.61, 616.52], [698.94, 553.81], [684.94, 492.46], [267.06, 444.71], [324.07, 411.28], [388.04, 399.12], [455.35, 403.36], [513.85, 427.96], [591.69, 429.43], [622.14, 409.39], [654.57, 395.43], [684.33, 389.74], [702.44, 404.0], [557.81, 482.21], [572.92, 526.38], [590.86, 570.97], [607.17, 616.77], [499.55, 660.01], [536.89, 671.35], [574.02, 684.11], [603.2, 672.55], [625.74, 657.11], [327.69, 484.1], [371.86, 468.99], [415.76, 465.4], [447.54, 494.71], [412.69, 505.42], [368.22, 503.14], [587.3, 488.05], [618.59, 462.35], [653.8, 458.91], [674.11, 477.84], [653.98, 496.53], [620.61, 497.34], [396.38, 770.42], [465.34, 734.43], [531.14, 719.65], [563.25, 727.32], [589.19, 718.17], [610.34, 731.43], [615.4, 765.44], [603.27, 798.32], [580.89, 822.46], [552.34, 829.77], [516.35, 828.75], [458.43, 810.01], [419.64, 769.54], [525.46, 757.83], [558.41, 759.84], [584.92, 756.56], [598.01, 765.74], [584.44, 769.5], [558.92, 775.82], [524.35, 775.01]]\n",
      "[75.57, 389.74, 702.61, 957.77]\n",
      "34995_face.jpg D:/Notebook/CMFD/34000/34995_face.jpg [[203.24, 449.16], [217.3, 528.45], [235.68, 610.35], [251.91, 690.94], [279.84, 766.8], [328.59, 830.17], [389.07, 881.44], [451.3, 924.93], [517.51, 939.84], [583.38, 923.57], [644.59, 873.52], [703.2, 820.42], [750.15, 757.33], [773.3, 687.25], [785.22, 608.9], [795.4, 530.98], [804.3, 447.86], [258.75, 420.74], [298.68, 388.81], [348.95, 376.4], [400.46, 383.91], [448.46, 407.0], [570.16, 400.85], [616.56, 380.2], [667.68, 371.25], [718.74, 384.39], [754.16, 416.11], [515.81, 478.64], [516.09, 531.91], [517.67, 583.01], [519.69, 635.85], [456.39, 662.52], [484.93, 673.86], [516.52, 682.61], [545.99, 675.33], [575.03, 666.32], [331.32, 483.74], [366.44, 469.55], [403.67, 471.39], [438.68, 494.01], [401.0, 497.8], [362.03, 496.39], [586.34, 496.17], [621.06, 472.89], [657.44, 471.26], [691.61, 483.05], [660.39, 498.12], [622.28, 500.17], [395.95, 745.49], [442.33, 732.2], [486.52, 724.96], [514.21, 732.84], [541.95, 725.99], [586.52, 735.21], [630.67, 742.7], [588.94, 797.14], [546.87, 820.4], [514.81, 824.64], [484.08, 819.36], [440.85, 793.25], [413.7, 750.3], [486.46, 747.05], [513.29, 751.45], [543.62, 747.64], [613.77, 748.71], [544.81, 782.29], [516.22, 785.67], [487.66, 781.69]]\n",
      "[203.24, 371.25, 804.3, 939.84]\n",
      "34996_face.jpg D:/Notebook/CMFD/34000/34996_face.jpg [[188.68, 520.44], [189.8, 598.05], [197.56, 678.52], [214.81, 755.23], [251.24, 827.62], [309.7, 889.06], [374.08, 940.46], [444.0, 975.37], [522.33, 987.15], [596.17, 976.54], [655.3, 934.38], [700.61, 876.82], [735.88, 813.35], [757.89, 744.15], [770.03, 672.27], [769.09, 597.89], [765.11, 526.92], [277.53, 431.31], [320.34, 386.84], [378.05, 377.12], [440.25, 389.81], [496.55, 412.54], [554.98, 415.73], [605.69, 396.71], [656.76, 384.13], [705.88, 394.32], [731.18, 441.44], [522.39, 469.34], [528.33, 517.56], [530.87, 562.72], [536.99, 614.16], [457.97, 647.72], [494.0, 655.41], [530.39, 669.55], [565.52, 661.1], [600.64, 652.66], [338.86, 486.12], [367.17, 471.59], [399.61, 473.0], [432.96, 490.55], [397.48, 492.54], [365.03, 491.12], [591.77, 494.58], [623.12, 476.63], [655.57, 478.05], [685.51, 492.55], [656.65, 497.41], [624.21, 495.99], [369.12, 736.85], [425.92, 711.01], [486.86, 701.12], [526.11, 708.62], [567.87, 703.04], [620.21, 713.05], [663.97, 742.95], [619.2, 810.19], [571.89, 832.27], [526.73, 834.8], [477.97, 831.07], [421.13, 798.66], [385.43, 739.17], [484.9, 723.88], [527.2, 727.98], [569.14, 725.62], [651.24, 746.9], [569.72, 793.55], [527.96, 799.13], [482.43, 795.22]]\n",
      "[188.68, 377.12, 770.03, 987.15]\n",
      "34997_face.jpg D:/Notebook/CMFD/34000/34997_face.jpg [[71.51, 476.32], [71.56, 571.2], [75.32, 663.08], [102.53, 757.47], [165.39, 835.32], [247.86, 888.16], [341.09, 935.37], [429.76, 961.76], [497.83, 958.85], [531.2, 931.91], [543.26, 882.37], [560.81, 813.09], [583.63, 757.92], [606.81, 699.4], [623.64, 636.81], [630.43, 573.16], [622.74, 518.13], [287.58, 451.91], [345.11, 420.77], [408.63, 397.05], [475.99, 400.84], [531.16, 423.66], [608.93, 425.17], [634.88, 404.22], [656.05, 396.31], [672.45, 401.45], [673.65, 421.9], [568.28, 488.61], [584.1, 530.95], [603.27, 573.65], [622.08, 619.71], [514.78, 672.65], [548.29, 676.22], [581.43, 683.14], [605.96, 675.59], [621.14, 660.27], [348.02, 488.85], [394.07, 470.04], [438.34, 467.98], [469.34, 495.0], [437.4, 508.54], [390.14, 506.89], [571.99, 485.61], [602.01, 458.32], [632.87, 454.83], [644.13, 476.36], [631.94, 495.39], [598.08, 495.17], [408.84, 776.56], [479.77, 746.85], [542.57, 729.82], [569.02, 736.03], [586.84, 727.77], [599.53, 735.89], [593.68, 758.99], [585.33, 805.54], [572.06, 834.62], [547.54, 842.17], [520.38, 842.66], [464.86, 823.19], [425.94, 774.99], [536.37, 756.27], [563.53, 755.78], [580.99, 750.86], [583.27, 761.27], [576.35, 794.41], [554.82, 805.67], [531.01, 806.52]]\n",
      "[71.51, 396.31, 673.65, 961.76]\n",
      "34998_face.jpg D:/Notebook/CMFD/34000/34998_face.jpg [[69.4, 477.1], [78.4, 577.51], [87.39, 676.95], [115.69, 771.51], [175.79, 846.65], [260.93, 900.47], [360.5, 933.0], [459.06, 952.99], [540.18, 949.84], [589.35, 924.58], [610.43, 870.44], [628.6, 812.44], [643.88, 755.42], [656.25, 693.58], [660.89, 631.76], [654.92, 574.8], [639.33, 527.52], [290.44, 439.74], [351.18, 407.68], [418.72, 388.16], [487.3, 391.82], [545.32, 417.72], [588.8, 423.38], [611.93, 408.82], [637.98, 402.95], [659.25, 409.65], [663.18, 432.81], [566.74, 474.63], [582.32, 516.11], [599.82, 556.62], [618.3, 600.02], [518.03, 653.43], [551.85, 660.09], [584.71, 667.72], [607.86, 660.89], [624.24, 646.35], [364.92, 479.1], [401.58, 466.44], [432.48, 465.38], [456.68, 485.59], [430.62, 489.53], [400.68, 487.69], [576.44, 490.05], [601.51, 477.42], [620.83, 477.36], [630.53, 491.82], [618.95, 496.68], [597.71, 495.78], [449.82, 771.46], [512.52, 746.16], [558.84, 735.4], [580.11, 742.09], [590.71, 735.3], [597.49, 743.97], [590.8, 764.27], [594.69, 774.88], [590.86, 784.55], [579.28, 787.48], [558.03, 786.58], [512.62, 780.93], [468.15, 765.61], [557.94, 756.65], [578.22, 757.55], [587.87, 754.62], [583.06, 762.36], [590.78, 760.41], [580.17, 764.3], [560.85, 762.43]]\n",
      "[69.4, 388.16, 663.18, 952.99]\n",
      "34999_face.jpg D:/Notebook/CMFD/34000/34999_face.jpg [[253.32, 523.54], [254.83, 584.3], [258.6, 641.83], [267.34, 701.9], [284.77, 763.28], [315.7, 817.8], [364.14, 862.5], [421.64, 894.32], [493.96, 910.59], [566.9, 910.92], [636.45, 898.28], [697.93, 868.4], [746.38, 818.75], [772.03, 754.97], [789.77, 684.66], [804.03, 613.82], [813.33, 540.46], [288.3, 445.15], [316.71, 410.28], [364.6, 399.71], [412.91, 398.1], [464.07, 412.95], [545.98, 412.85], [598.65, 394.1], [655.14, 397.29], [709.52, 414.41], [747.78, 455.79], [506.5, 462.08], [506.73, 495.94], [504.95, 531.27], [504.65, 568.61], [452.99, 616.0], [480.31, 623.69], [507.64, 631.37], [537.06, 625.14], [566.49, 618.9], [335.95, 495.07], [366.17, 483.61], [396.81, 481.12], [434.57, 490.38], [400.45, 492.35], [369.81, 494.85], [587.68, 490.36], [624.86, 479.95], [656.45, 482.94], [689.94, 496.9], [656.35, 495.39], [624.49, 494.14], [376.3, 711.23], [420.64, 676.98], [470.52, 664.93], [508.55, 672.46], [544.94, 667.27], [598.11, 680.64], [648.39, 713.16], [595.51, 756.8], [543.62, 770.33], [504.02, 773.25], [465.46, 769.2], [417.51, 756.62], [389.01, 709.59], [470.59, 688.09], [509.14, 692.13], [545.01, 690.42], [634.2, 712.79], [542.61, 741.69], [503.26, 742.87], [464.44, 740.57]]\n",
      "[253.32, 394.1, 813.33, 910.92]\n"
     ]
    }
   ],
   "source": [
    "#读取json文件之后，对图片进行批量标注\n",
    "outdir = 'Annotation'\n",
    "for i in range(35000):\n",
    "    file_path = data[str(i)]['thumbnail']['file_path']\n",
    "    image_name = file_path.split('/')[2].split('.')[0]+'_face.jpg'\n",
    "    file_path = file_path.split('/')[1]+'/'+file_path.split('/')[2].split('.')[0]+'_face.jpg'\n",
    "    our_image_path  = 'D:/Notebook/CMFD'+'/'+file_path\n",
    "\n",
    "    face_landmarks = data[str(i)]['image']['face_landmarks']\n",
    "    print(image_name,our_image_path,face_landmarks)\n",
    "    face_rect = darw_face_rect(face_landmarks) \n",
    "    create_tree(image_name, 1024, 1024, our_image_path)\n",
    "    create_object(annotation, int(face_rect[0]), int(face_rect[1]), int(face_rect[2]), int(face_rect[3]), 'wrmask')\n",
    "\n",
    "    # 将树模型写入xml文件\n",
    "    tree = ET.ElementTree(annotation)\n",
    "    root = tree.getroot()\n",
    "    pretty_xml(root, '\\t', '\\n')\n",
    "    tree.write('.\\{}\\{}.xml'.format(outdir, image_name.strip('.jpg')), encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "#批量修改文件名,并移动"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "tags": [
     "outputPrepend"
    ]
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "25_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34726_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34728_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34729_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34730_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34731_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34732_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34733_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34734_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34735_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34736_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34737_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34738_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34739_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34740_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34741_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34742_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34743_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34744_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34745_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34746_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34747_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34748_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34749_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34750_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34751_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34753_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34754_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34755_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34756_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34757_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34758_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34759_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34760_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34761_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34762_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34763_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34764_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34765_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34766_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34767_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34768_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34769_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34770_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34771_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34772_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34773_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34774_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34775_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34776_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34777_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34778_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34779_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34780_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34781_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34782_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34783_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34784_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34785_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34786_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34787_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34788_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34789_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34790_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34791_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34792_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34793_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34794_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34795_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34796_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34797_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34798_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34799_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34800_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34801_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34802_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34803_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34804_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34805_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34806_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34807_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34808_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34809_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34810_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34811_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34812_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34813_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34814_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34815_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34816_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34817_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34818_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34819_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34820_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34821_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34822_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34823_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34825_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34826_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34827_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34828_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34829_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34831_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34832_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34833_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34834_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34835_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34836_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34837_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34838_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34839_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34840_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34841_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34842_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34843_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34844_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34845_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34846_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34847_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34848_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34849_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34850_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34851_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34852_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34853_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34854_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34855_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34856_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34857_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34858_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34859_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34860_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34861_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34863_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34864_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34865_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34866_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34867_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34869_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34870_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34871_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34872_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34873_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34874_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34875_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34876_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34877_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34878_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34879_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34880_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34881_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34882_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34883_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34884_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34885_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34886_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34887_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34888_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34890_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34891_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34892_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34893_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34894_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34895_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34896_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34897_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34898_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34899_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34900_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34901_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34902_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34903_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34904_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34905_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34906_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34907_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34908_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34909_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34911_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34912_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34913_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34914_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34915_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34916_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34917_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34918_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34919_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34920_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34921_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34922_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34923_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34924_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34925_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34926_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34927_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34928_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34929_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34930_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34931_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34932_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34933_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34934_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34935_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34936_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34937_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34938_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34939_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34940_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34941_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34942_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34943_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34944_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34945_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34946_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34947_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34948_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34949_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34950_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34951_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34952_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34953_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34954_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34955_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34956_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34957_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34958_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34959_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34960_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34961_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34962_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34963_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34964_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34965_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34966_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34967_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34968_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34969_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34970_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34971_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34972_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34973_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34974_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34975_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34977_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34978_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34979_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34980_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34981_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34982_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34983_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34984_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34985_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34986_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34987_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34988_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34989_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34990_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34991_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34992_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34993_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34994_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34995_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34996_Mask.jpg\n",
      "D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/34999_Mask.jpg\n"
     ]
    }
   ],
   "source": [
    "import glob, os, shutil\n",
    "from os import getcwd\n",
    "from os import listdir\n",
    "import cv2\n",
    "import numpy as np\n",
    "\n",
    "image_dir = 'D:/Notebook/CMFD'\n",
    "for root,dirs,files in os.walk(image_dir):\n",
    "    for file in files: \n",
    "        if '.jpg' in file: # 只查找jpg文件\n",
    "            old_file_path = os.path.join(root,file)\n",
    "            new_file_name = old_file_path.split(\"\\\\\")[2].split('_')[0]+'_Mask'\n",
    "            new_file_path = 'D:/Notebook/yolov4-tiny-pytorch/VOCdevkit/VOC2007/JPEGImages/'+new_file_name+'.jpg'\n",
    "            shutil.copyfile(old_file_path, new_file_path)\n",
    "            print(new_file_path)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}